package com.example.callfor.api;


import com.example.callfor.model.Message;
import com.example.callfor.model.MessageMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class MessageApi {

    @Resource
    private MessageMapper messageMapper;

    @PostMapping("/leaveMessage")
    public Object leaveMessage(String person,String message,String time){
        Message leave_message = new Message();
        leave_message.setPerson(person);
        leave_message.setMessage(message);
        leave_message.setTime(time);
        messageMapper.addMessage(leave_message);
        return 1;
    }

    /**
     * 查询留言
     * @return
     */
    @GetMapping("/message")
    public Object getMessage(){
        return messageMapper.getMessage();
    }

    @PostMapping("/delMessage")
    public Object delMessage(int id){
        return messageMapper.deleteMessage(id);
    }
}
